package com.study.singleton;


/**
 * 验证枚举类是单例的
 */
public class EnumSingletonTest {
    public static void main(String[] args) {

        EnumSingleton instance = EnumSingleton.INSTANCE;

        EnumSingleton instance2 = EnumSingleton.INSTANCE;

        //这肯定就是true了
        System.out.println(instance2 == instance);

    }
}


enum EnumSingleton{
    INSTANCE;
    public void print(){
        System.out.println("xxx");
    }
}